package com.xianyun.site.support;

import com.alibaba.cola.dto.Response;
import com.alibaba.fastjson.JSONObject;
import com.xianyun.site.support.api.ReceiveService;
import com.xianyun.site.support.api.ReceiveStrategy;
import com.xianyun.site.support.dto.ReceiveCmd;
import com.xianyun.site.support.executor.commond.SupportMessageExo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.validation.Valid;

/**
 * @author mac_zyj
 */
@Slf4j
@Service
public class ReceiveServiceImpl implements ReceiveService {
    @Autowired
    private ReceiveStrategy receiveStrategy;

    @Autowired
    private SupportMessageExo  supportMessageExo;

    @Override
    public Response sendSupportMessage(@Valid ReceiveCmd receiveCmd, JSONObject receiveObject) {
        receiveStrategy.analysisStrategy(receiveCmd);
        receiveStrategy.operateCodeAnalysis(receiveCmd);
        receiveStrategy.feasibilityAnalysis(receiveCmd);
        log.info("解析完成 CMD:{}",receiveCmd.getCheckParam());
        return supportMessageExo.execute(receiveCmd, receiveObject);
    }
}
